Builds a list, using an iterator function and an initial seed value.
The iterator function accepts one argument (seed) and must always return a list with two elements ([value, nextSeed]) or False to terminate. Use a generator function, fn_generator, that uses a while loop to call the iterator function and yield the value until it returns False. Use a list comprehension to return the list that is produced by the generator, using the iterator function.
CODE:
def unfold(fn, seed): def fn_generator(val): while True: val = fn(val[1]) if val == False: break yield val[0] return [i for i in fn_generator([None, seed])]
f = lambda n: False if n > 50 else [-n, n + 10] INPUT: unfold(f, 10)
Builds a list, using an iterator function and an initial seed value.
The iterator function accepts one argument (seed) and must always return a list with two elements ([value, nextSeed]) or False to terminate. Use a generator function, fn_generator, that uses a while loop to call the iterator function and yield the value until it returns False. Use a list comprehension to return the list that is produced by the generator, using the iterator function.
CODE:
def unfold(fn, seed): def fn_generator(val): while True: val = fn(val[1]) if val == False: break yield val[0] return [i for i in fn_generator([None, seed])]
f = lambda n: False if n > 50 else [-n, n + 10] INPUT: unfold(f, 10)
Telegram has made it easier for its users to communicate, as it has introduced a feature that allows more than 200,000 users in a group chat. However, if the users in a group chat move past 200,000, it changes into "Broadcast Group", but the feature comes with a restriction. Groups with close to 200k members can be converted to a Broadcast Group that allows unlimited members. Only admins can post in Broadcast Groups, but everyone can read along and participate in group Voice Chats," Telegram added.
Traders also expressed uncertainty about the situation with China Evergrande, as the indebted property company has not provided clarification about a key interest payment.In economic news, the Commerce Department reported an unexpected increase in U.S. new home sales in August.Crude oil prices climbed Friday and front-month WTI oil futures contracts saw gains for a fifth straight week amid tighter supplies. West Texas Intermediate Crude oil futures for November rose $0.68 or 0.9 percent at 73.98 a barrel. WTI Crude futures gained 2.8 percent for the week.